parse arg args;options cache;options failat 99;options results;signal on break_c;signal on break_d;signal on break_e;signal on break_f;signal on halt;signal on ioerr;signal on syntax;address 'MAILMANAGER';Main:;call Init;call Header;call Parse_Args(strip(args));MM_ReadStem system.prg.cfg 'system.cfg';if system.arg.get then ret = Get_Cfg(system.arg.node);if system.arg.set then ret = Set_Cfg(system.arg.node, system.arg.archiver, system.arg.name);if system.changed then do;MM_CopyFile system.prg.cfg system.prg.cfg;MM_WriteStem system.prg.cfg 'system.cfg';end;call Quit(ret, 'All done.');exit;break_c:; break_d:; break_e:; break_f:; halt:;signal off break_c;signal off break_d;signal off break_e;signal off break_f;signal off halt;return_code = 5;error_line = 0;error_msg = 'Execution halted!!!';rc = 0;signal Exit;Build_Line: procedure Expose system.;parse arg node, arcer, name;line = '#ARCNODE ' left(node, max(29, length(node)+1));if arcer~='' then line = line 'ARCHIVER' left(arcer, max(5, length(arcer)+1))
if name~='' then line = line 'NAME' name;return strip(line);Exit:;select;when return_code>=40 then error = 'INTERNAL-ERROR:';when return_code>=30 then error = 'IO-ERROR:';when return_code>=20 then error = 'ERROR:';when return_code>=10 then error = 'WARNING:';when return_code>=5 then error = 'INFO:';otherwise error = '';end;tmp = '***' strip(error error_msg) '***';if return_code>5 then say tmp;call Log();call Log(tmp, '+');call Log(,'\');call setclip('MM_LogPre', system.mm.logpre);exit return_code;Get_Arg: procedure Expose args system.;arg keyword, mode, old;uargs = upper(args);p = find(uargs, keyword);if p=0 then do;p = pos(' 'keyword'=', ' 'uargs);if p>0 then args = overlay(' ', args, p+length(keyword));p = find(upper(args), keyword);end;system.cmdopt.keyword = p>0;select;when mode=0 then if p>0 then do;ret = 1;args = delword(args, p, 1);end;else ret = old;when mode=1 then if p>0 then do;left = subword(args, 1, p-1);rest = subword(args, p+1);if left(rest, 1)='"' then parse var rest . '"' ret '"' rest
else parse var rest ret rest;args = strip(left strip(rest));end;else ret = old;when mode=2 then do;if left(args, 1)='"' then parse var args . '"' ret '"' args;else parse var args ret args;if strip(ret)='' then ret = old;end;otherwise exit 99;end;args = strip(args);ret = strip(ret, 'b', '" ');return ret;Get_Cfg: procedure Expose system.;parse arg node;ret. = '';MM_SearchInStem 'system.cfg' 'ret' '"?ARCNODE#?'node'#?"' 'STR';say ret.0;call setclip('MM_BundleFiles_Cfg', ret.0);return (ret.0='')*5;Get_Version: procedure;parse arg mode;parse value sourceline(3-mode) with . . ver .;parse var ver tst 'ß' .;if ~datatype(strip(tst, 'b', '/ce '), 'N') then if ~mode then ver = Get_Version(1);else exit 99;return ver;Header:;call Log(,'/');call Log('***' system.prg.id '***', '+');call Log(' 'system.prg.cr);call Log();return;Init:;system. = 0;system.prg.ver = Get_Version(0);system.prg.name = 'MM_BundleFiles_SetCfg';system.prg.id = system.prg.name 'v'system.prg.ver;system.prg.cfg = 'MM:Config/MM_BundleFiles.cfg'